package com.xs.tool.common.jwt;

import com.auth0.jwt.JWT;
import com.auth0.jwt.algorithms.Algorithm;
import com.xs.tool.model.User;

public class JwtUtil {
    /**
     * 生成token
     * @param user
     * @return
     */
    public static String getToken(User user) {
        String token="";
        try {
            token= JWT.create().withAudience(user.getId()+"")
                    .sign(Algorithm.HMAC256(user.getPassword()));
        }catch (Exception e){
            e.printStackTrace();
        }
        return token;
    }
}
